using System;
using UnityEngine;

[ExecuteInEditMode]
public class ControllerPlatformMobileSlopeTarget : ControllerGeneric
{
	private static float unit = 0.25f;

	public float length = 10f;

	public float height = 6f;

	public float width = 1f;

	public GameObject prisma1;

	public GameObject prisma2;

	public GameObject cub;

	public GameObject prisma3;

	public GameObject prisma4;

	public float unghiRampa;

	public RemoteControl platformRC;

	private void Update()
	{
		if (!Application.isEditor || Application.isPlaying)
		{
			return;
		}
		if (platformRC == null)
		{
			UnityEngine.Object.DestroyImmediate(base.gameObject);
			return;
		}
		SetupRemoteControl();
		if (IsRemoteControlActive())
		{
			remoteControl.transform.rotation = platformRC.transform.rotation;
			remoteControl.transform.localScale = platformRC.transform.localScale;
			base.transform.position = remoteControl.transform.position;
			base.transform.rotation = remoteControl.transform.rotation;
			length = remoteControl.transform.localScale.z;
			height = remoteControl.transform.localScale.y;
			width = remoteControl.transform.localScale.x;
		}
		Setup();
	}

	private void Setup()
	{
		AssureParenting();
		float platformMobileSlopeHeight = ControllerPlatformMobileSlope.platformMobileSlopeHeight;
		Vector3 zero = Vector3.zero;
		Vector3 one = Vector3.one;
		Vector3 zero2 = Vector3.zero;
		float num = Mathf.Sqrt(length * length + (height - 2f * platformMobileSlopeHeight) * (height - 2f * platformMobileSlopeHeight));
		float num2 = Mathf.Sqrt(num * num - platformMobileSlopeHeight * platformMobileSlopeHeight);
		float num3 = Mathf.Acos(length / num) * 57.29578f;
		float num4 = Mathf.Acos(num2 / num) * 57.29578f;
		float num5 = num3 + num4;
		zero = new Vector3(0f, height * 0.5f, length * 0.5f);
		one.z = num2 / unit;
		one.y = platformMobileSlopeHeight / unit;
		one.x = width / unit;
		zero2.x = 0f - num5;
		float num6 = (height - platformMobileSlopeHeight) / Mathf.Sin(num5 * ((float)Math.PI / 180f));
		float num7 = num6 - num2;
		float num8 = num7 * Mathf.Sin(num5 * ((float)Math.PI / 180f));
		float num9 = platformMobileSlopeHeight * Mathf.Cos((90f - num5) * ((float)Math.PI / 180f));
		Vector3 one2 = Vector3.one;
		one2.y = num7 / unit;
		one2.z = platformMobileSlopeHeight / unit;
		one2.x = width / unit;
		if (cub != null)
		{
			cub.transform.localPosition = zero - new Vector3(0f, height / 2f, length / 2f);
			cub.transform.localEulerAngles = zero2;
			cub.transform.localScale = one;
		}
		if (prisma1 != null)
		{
			prisma1.transform.localPosition = Vector3.zero - new Vector3(0f, height / 2f, length / 2f);
			prisma1.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
			prisma1.transform.localScale = one2;
		}
		if (prisma2 != null)
		{
			prisma2.transform.localPosition = new Vector3(0f, num8, num9) - new Vector3(0f, height / 2f, length / 2f);
			prisma2.transform.localEulerAngles = new Vector3(90f + num5, 180f, 0f);
			prisma2.transform.localScale = one2;
		}
		if (prisma3 != null)
		{
			prisma3.transform.localPosition = new Vector3(0f, height - num8, length - num9) - new Vector3(0f, height / 2f, length / 2f);
			prisma3.transform.localEulerAngles = new Vector3(-90f + num5, 180f, 0f);
			prisma3.transform.localScale = one2;
		}
		if (prisma4 != null)
		{
			prisma4.transform.localPosition = new Vector3(0f, height, length) - new Vector3(0f, height / 2f, length / 2f);
			prisma4.transform.localEulerAngles = new Vector3(-90f, 0f, 0f);
			prisma4.transform.localScale = one2;
		}
	}

	public void SetupRemoteControl()
	{
		if (remoteControl == null)
		{
			InitRemoteControl();
			remoteControl.gameObject.name = remoteControl.gameObject.name + base.name;
			remoteControl.gameObject.transform.position = base.transform.position;
			remoteControl.gameObject.transform.rotation = base.transform.rotation;
			remoteControl.gameObject.transform.localScale = new Vector3(width, height, length);
			remoteControl.destroyable = false;
			remoteControl.duplicable = false;
		}
	}

	public void SetupUVs()
	{
	}
}
